#delattr
Description: Deletes a specified attribute. See also the hasattr, getattr, and setattr functions.
def delattr(obj, name: str):
'''
Deletes a specified attribute
:param obj: An object
:param name: The name of the attribute to delete
'''
Example:
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
p = Person("Alice", 30)
print(p.name)
# Delete the 'name' attribute
delattr(p, 'name')
try:
print(p.name)
except AttributeError as e:
print(f"Error: {e}") # Output: Error: 'Person' object has no attribute 'name'